Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

test-runner

Package Overview
Dependencies
Maintainers
1
Versions
93
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

test-runner

Minimal, extensible test runner.

  • 0.4.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
313
decreased by-43.91%
Maintainers
1
Weekly downloads
 
Created
Source

view on npm npm module downloads Build Status Dependency Status js-standard-style

test-runner

A minimal test runner built around a single, core principle: if a test function completes successfully (or fulfils), it passes. If it throws (or rejects) it fails. It has no opinion how you write tests, or which (if any) assertion library you use.

const TestRunner = require('test-runner')
const runner = new TestRunner()

Synopsis

Passing test, sync.

runner.test('this will pass', function () {
  const thought = 'Nothing failing here.'
})

Passing test, async.

runner.test('this will also pass', function () {
  return Promise.resolve('Nothing failing here.')
})

Failing test, sync.

runner.test('this will fail', function () {
  throw new Error('Definitely something wrong here.')
})

Failing test, async.

runner.test('this will also fail', function () {
  return Promise.reject('Definitely something wrong here.')
})

To run the tests, execute the script:

$ node test.js

... or use the command-line tool to test multiple files:

$ test-runner test/*.js

test-runner

TestRunner ⇐ EventEmitter

Register tests and run them sequentially or in parallel. By default, testing begins automatically but can be set to start manually.

Kind: Exported class
Extends: EventEmitter

new TestRunner([options])
ParamTypeDescription
[options]object
[options.log]functionSpecify a custom log function. Defaults to console.log.
[options.manualStart]booleanIf true, you must call runner.start() manually.
[options.sequential]booleanRun async tests sequentially.

testRunner.start() ⇒ Promise

Begin testing. You'll only need to use this method when manualStart is true.

Kind: instance method of TestRunner
Fulfil: Array - Resolves with an array containing the return value of each test.

testRunner.test(name, testFunction) ↩︎

Register a test.

Kind: instance method of TestRunner
Chainable

ParamTypeDescription
namestringEach name supplied must be unique to the runner instance.
testFunctionfunctionThe test function. If it throws or rejects, the test will fail.

testRunner.skip() ↩︎

No-op. Use this method when you want a test to be skipped.

Kind: instance method of TestRunner
Chainable

testRunner.only(name, testFunction) ↩︎

Only run this and other tests registered with only.

Kind: instance method of TestRunner
Chainable

ParamType
namestring
testFunctionfunction

TestRunner.run(globs) ⇒ Array

Run one or more test files. The output will be an array containing the export value from each module.

Kind: static method of TestRunner

ParamTypeDescription
globsArray.<string>One or more file paths or glob expressions.

© 2016-17 Lloyd Brookes <75pound@gmail.com>. Documented by jsdoc-to-markdown.

Keywords

FAQs

Package last updated on 09 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc